export default ({ http }) => ({
  /**
   * 课程
   */

  // 点播-详情
  getCourseDetail(id, response, error) {
    return http.get(`/course/base/${id}`, {}, response, error)
  },

  // 课程列表
  getCourseList(query, response, error) {
    return http.get('/course/base/list', query, response, error)
  },

  // 点播-章节目录
  getCourseSection(id, pid, query, response, error) {
    return http.get(`/course/base/${id}/section/${pid}`, query, response, error, false)
  },

  // 班级-章节目录
  getCourseClassesMenu(id, response, error) {
    return http.get(`/course/classes/${id}/menu`, {}, response, error)
  },

  // 课时链接
  getCourseSectionFileurl(id, sid, query, response, error) {
    return http.get(`/course/base/${id}/section/${sid}/fileurl`, query, response, error, false)
  },

  // 添加学习记录
  createCourseRecord(query, response, error) {
    return http.post(`/course/base/record`, query, response, error, false)
  },
  // 课程 - 通用搜索
  getCourseSearch(query, response) {
    return http.get('/course/base/search', query, response)
  },

  // 用户加入免费课程
  createCourseStudentJoin(query, response, error) {
    return http.post('/course/student/join', query, response, error, false)
  },

  /**
   * 课程-点评
   */

  // 列表
  getCourseComment(id, query, response) {
    return http.get(`/course/base/${id}/comment`, query, response)
  },

  // 添加点评（修改点评）
  createCourseComment(id, query, response, error) {
    return http.post(`/course/base/${id}/comment`, query, response, error, false)
  },

  // 点评评论列表
  getCourseCommentReply(id, query, response, error) {
    return http.get(`/course/base/comment/${id}/reply`, query, response, error, false)
  },

  // 评论点评或回复评论（@用户）
  createCourseCommentReply(id, query, response, error) {
    return http.post(`/course/base/comment/${id}/reply`, query, response, error)
  },

  // 点赞
  updateCourseCommentlike(id, query, response, error) {
    return http.put(`/course/base/comment/${id}/like`, query, response, error, false)
  },

  // 删除评论
  deleteCourseComment(id, response, error) {
    return http.delete(`/course/base/comment/${id}`, {}, response, error, false)
  },

  // 删除评论回复
  deleteCourseCommentReply(id, response, error) {
    return http.delete(`/course/base/comment/reply/${id}`, {}, response, error, false)
  },

  /**
   * 课程-卡券
   */

  // 机构对应的卡券
  getCouponSchool(query, response, error) {
    return http.get('/course/coupon/school', query, response, error, false)
  },

  // 领取
  createCouponDerive(id, query, response, error) {
    return http.post(`/course/coupon/${id}/derive`, query, response, error, false)
  },

  //  用户领取的对应机构卡券
  getCouponSchoolUser(query, response, error) {
    return http.get('/course/coupon/school/user', query, response, error, false)
  },

  // 课程可用的卡券
  getCouponCourse(query, response) {
    return http.get(`/course/coupon/course`, query, response)
  },

  // 课程可用的卡券-用户领取的卡券
  getCouponCourseUser(query, response) {
    return http.get(`/course/coupon/course/user`, query, response)
  },

  // 课程卡直接兑换
  getCouponCourseExchange(query, response, error) {
    return http.post(`/course/coupon/exchange`, query, response, error, false)
  },

  /**
   * 课程-笔记
   */
  // 笔记列表
  getCourseNoteList(query, response, error) {
    return http.get(`course/base/note/list`, query, response, error, false)
  },

  // 笔记添加
  createCourseNote(query, response, error) {
    return http.post(`/course/base/note`, query, response, error)
  },

  // 笔记修改
  updateCourseModifyNote(id, query, response, error) {
    return http.put(`/course/base/note/${id}`, query, response, error, false)
  },

  /**
   * 活动
   */
  // 课程开团列表
  getPromotionPintuanList(query, response) {
    return http.get(`/promotion/pintuan/list`, query, response, {}, false)
  },

  // 支付前发起拼团
  postPromotionPintuanCreate(query, response, error) {
    return http.post(`/promotion/pintuan/create`, query, response, error)
  },

  // 支付前加入拼团
  postPromotionPintuanJoin(query, response, error) {
    return http.post(`/promotion/pintuan/join`, query, response, error)
  },

  // 拼团详情
  getPromotionPintuanDetail(query, response, error) {
    return http.get(`/promotion/pintuan/detail`, query, response, error, false)
  },

  // 用户砍价详情
  getPromotionBargainDetail(query, response) {
    return http.get(`/promotion/bargain/detail`, query, response, {}, false)
  },

  // 好友帮砍
  postPromotionBargainDoit(query, response, error) {
    return http.post(`/promotion/bargain/doit`, query, response, error, false)
  },

  // 推荐课程
  getCourseSplendid(id, response) {
    return http.get(`/course/base/${id}/splendid`, {}, response)
  },

  // 课程点播课时云端视频数据
  getCourseSectionVideo(id, sid, stock, response) {
    return http.get(`/course/base/${id}/section/${sid}/video/${stock}`, {}, response)
  },

  // 当前课时是否解锁
  getCourseUnlock(query, response, error) {
    return http.get(`/course/unlock`, query, response, error, false)
  },

  // 课程弹题数据
  getCourseQuestion(id, query, response, error) {
    return http.get(`/course/base/${id}/question`, query, response, error, false)
  },

  // 课程课件列表
  getCourseCourseware(id, response, error) {
    return http.get(`/course/base/${id}/courseware`, {}, response, error)
  },

  // 添加课程课件下载记录
  postCourseCoursewareRecord(query, response, error) {
    return http.post(`/course/base/courseware/record`, query, response, error, false)
  }
})
